#pragma once

namespace TextureSynthesizer
{
	class MultiScalePyramid
	{
		IplImage** m_Images;
	public:
		unsigned int Levels;
		MultiScalePyramid(IplImage* image, float scaleFactor, unsigned int numberOfLevels, int interpolation = CV_INTER_CUBIC) : Levels(numberOfLevels)
		{
			m_Images = new IplImage*[Levels];

			m_Images[0] = cvCloneImage(image);

			for(unsigned int level = 1 ; level < Levels ; level++)
			{
				m_Images[level] = cvCreateImage(cvSize((int)(m_Images[level-1]->width * scaleFactor), (int)(m_Images[level-1]->height * scaleFactor)), 8, image->nChannels);
				cvResize(m_Images[level-1], m_Images[level], CV_INTER_CUBIC);
			}
		}
		~MultiScalePyramid(void)
		{
			for(unsigned int level = 0 ; level < Levels ; level++)
			{
				cvReleaseImage(&m_Images[level]);
			}
			delete [] m_Images;
			m_Images = NULL;
		}

		IplImage* operator[](unsigned int level)
		{
			return m_Images[level];

		}
		
		IplImage* Get(unsigned int level) const
		{
			return m_Images[level];

		}
	};
};